
// 模拟请求
function req(promise,time = 5000) {
    return Promise.race([
        promise,
        new Promise(((resolve, reject) => {
            setTimeout(() => {
                reject(new Error("cuole"))
            },time)
        }))
    ])
}
const p = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve("得到响应了")
    },6000)
})
req(p,5000).then((resolve,reject) => {
    console.log(resolve);
    console.log(reject)
},(error) => {
    console.log(error.message);
})
